package jianzhiOfferII;

public class Num003_countBits {
    public int[] countBits(int n) {
        int []data = new int[n+1];
        for (int i = 0; i < data.length; i++) {
            data[i] = count1(i);
        }
        return data;
    }
    //一个数二进制中1的个数
    public static int count1 (int x){
        int count = 0;

        while (x>0){
            x=x&(x-1);
            count++;

        }
        return count;
    }


}
